using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace UltimateDefend
{
    public partial class Form1 : Form
    {
        private Bitmap m_bitmap;
        private Bitmap m_bitmapBuff;
        private bool m_IsBack = false;
        private IMap map;
        private HeavyArmor h;
        private int k;

        public Form1()
        {
            InitializeComponent();
            this.m_bitmap = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);
            this.m_bitmapBuff = new Bitmap(this.ClientRectangle.Width, this.ClientRectangle.Height);

            this.k = 0;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            map = new MapLevel1();
            map.LoadMap(this.m_bitmap);

            //IEnemy enemy = new HeavyArmor(Graphics.FromImage(this.m_bitmap));

            h = new HeavyArmor(Graphics.FromImage(this.m_bitmap));
            this.Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.DrawImage(this.m_bitmapBuff, 0, 0);
            
        }
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            if (!this.m_IsBack)
            {
                this.m_IsBack = true;
            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            if (k < map.ListPointSolider.Length)
            {
                Graphics g = Graphics.FromImage(this.m_bitmapBuff);
                g.DrawImage(this.m_bitmap, 0, 0);
                this.m_bitmapBuff = h.Go(this.m_bitmapBuff, map.ListPointSolider[k]);
                k++;
                this.Invalidate();
            }            
            timer1.Enabled = true;
        }
    }
}